package com.ruoyi;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class HouseErrorMsg {
	
	protected static HashMap messages= new HashMap();;

	 /* 成功返回码的宏定义 */
	public static final String SUCCESS             = "000000"; // 成功
	public static final String ERR_DEFAULT             = "000001"; // 缺省错误
	public static final String ERR_UNKNOW              = "000002"; // 未知错误
	public static final String ERR_DB_ERROR            = "000003";
	public static final String ERR_QUERY_ERROR         = "000004";
	public static final String TCP_ERROR               = "000005";
	public static final String FILE_ERROR              = "000006";	
	public static final String REVERSE_DATE_ERROR      = "000007";
	public static final String NO_TRADE                = "000008";
	public static final String ERR_DATATIME            = "000009";
	public static final String NO_DOOR                 = "000010"; 
	public static final String CODE_ERROR              = "000011";
	public static final String NO_AREA                 = "000012";
	public static final String MONEY_ERROR             = "000013";
	public static final String BATCH_MONEY             = "000014";
	public static final String COSTTYPE_ERROR          = "000015";
	public static final String NO_CUSTNUMBER		   = "000016";
	public static final String NO_BILL      		   = "000017";
	public static final String NO_BILL1      		   = "000018";
	public static final String NO_BILL2      		   = "000019";
	public static final String NO_RATE1      		   = "000020";
	public static final String NO_RATE2      		   = "000021";
	public static final String STS_LOCK      		   = "000022";
	public static final String STS_LOCK_GROUP      	   = "000024";
	public static final String BILL_UESD      		   = "000023";
	public static final String NO_DATA     		       = "000025";
	public static final String UP_ERROR     		   = "000026";
	
	static{
		
			//成功返回码的宏定义
			messages.put(SUCCESS, "成功");
			messages.put(ERR_DEFAULT, "处理失败");
			messages.put(ERR_UNKNOW,  "未知错误");			
			messages.put(ERR_DB_ERROR, "数据库错误");
			messages.put(ERR_QUERY_ERROR, "查询失败");
			messages.put(TCP_ERROR, "通讯错误");
			messages.put(FILE_ERROR, "文件错误");
			messages.put(REVERSE_DATE_ERROR, "冲销日期错误");
			messages.put(NO_TRADE, "无此存款");
			messages.put(ERR_DATATIME, "时间格式错误");
			messages.put(NO_DOOR, "无该户信息");
			messages.put(CODE_ERROR, "交易码错误");
			messages.put(NO_AREA, "无该小区信息");
			messages.put(MONEY_ERROR, "该小区已有部分缴费");
			messages.put(BATCH_MONEY, "缴费金额错误");
			messages.put(COSTTYPE_ERROR, "缴费类别无效");
			messages.put(NO_CUSTNUMBER, "无此缴费编号");
			messages.put(NO_BILL, "请确认发票");
			messages.put(NO_BILL1, "请确认原始发票");
			messages.put(NO_BILL2, "请确认补打发票");
			messages.put(NO_RATE1, "更新活期利率失败");
			messages.put(NO_RATE2, "更新5年定期利率失败");
			messages.put(STS_LOCK, "该小区已被缴费锁定");
		    messages.put(STS_LOCK_GROUP, "该楼宇已被缴费锁定");
		    messages.put(BILL_UESD, "已开具发票");
		    messages.put(NO_DATA,"无查询数据");
		    messages.put(UP_ERROR,"账号密码错误");
	}
	
	public static String getMessage(String key) {
		
		String message = (String)messages.get(key);		//是否需要默认""?
		return message!=null ? message : "未知错误";
	}
	
	public static Map<String, String> getReturnStatus(Map<String, String> returnBodyMap){
		Map<String, String> statusMap = new HashMap<String, String>();
		if(!returnBodyMap.isEmpty()){
			if(returnBodyMap.get("ERROECODE")!= null){
				statusMap.put("stscode", returnBodyMap.get("ERROECODE"));
				statusMap.put("stsdesc", HouseErrorMsg.getMessage(returnBodyMap.get("ERROECODE")));
			}else{
				statusMap.put("stscode", HouseErrorMsg.SUCCESS);
				statusMap.put("stsdesc", HouseErrorMsg.getMessage(HouseErrorMsg.SUCCESS));
			}
		}else{
			statusMap.put("stscode", HouseErrorMsg.ERR_UNKNOW);
			statusMap.put("stsdesc", HouseErrorMsg.getMessage(HouseErrorMsg.ERR_UNKNOW));
		}
		return statusMap;
	}
	
	public static Map<String, String> getReturnStatus(List<Map<String, String>> returnBodyList){
		Map<String, String> statusMap = new HashMap<String, String>();
		if(!returnBodyList.get(0).isEmpty()){
			Map<String, String> codeMap = new HashMap<String, String>();
			codeMap = returnBodyList.get(0);
			if(codeMap.get("ERROECODE") != null){
				statusMap.put("stscode", returnBodyList.get(0).get("ERROECODE"));
				statusMap.put("stsdesc", HouseErrorMsg.getMessage(returnBodyList.get(0).get("ERROECODE")));
			}else{
				statusMap.put("stscode", HouseErrorMsg.SUCCESS);
				statusMap.put("stsdesc", HouseErrorMsg.getMessage(HouseErrorMsg.SUCCESS));
			}
		}else{
			statusMap.put("stscode", HouseErrorMsg.ERR_UNKNOW);
			statusMap.put("stsdesc", HouseErrorMsg.getMessage(HouseErrorMsg.ERR_UNKNOW));
		}
		return statusMap;
	}
	
	public static Map<String, String> getReturnStatus(String returnCode){
		Map<String, String> statusMap = new HashMap<String, String>();
		statusMap.put("stscode", returnCode);
		statusMap.put("stsdesc", HouseErrorMsg.getMessage(returnCode));
		return statusMap;
	}
}
